package com.qyhl.module_practice.volunteer.sign;

import android.annotation.SuppressLint;
import android.content.Intent;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.AdapterView;
import android.widget.CompoundButton;
import android.widget.EditText;
import android.widget.LinearLayout;
import android.widget.RadioGroup;
import android.widget.RelativeLayout;
import android.widget.Spinner;
import android.widget.TextView;
import android.widget.ToggleButton;

import androidx.cardview.widget.CardView;
import androidx.recyclerview.widget.GridLayoutManager;
import androidx.recyclerview.widget.RecyclerView;

import com.alibaba.android.arouter.facade.annotation.Autowired;
import com.alibaba.android.arouter.facade.annotation.Route;
import com.bumptech.glide.Glide;
import com.bumptech.glide.request.RequestOptions;
import com.gyf.immersionbar.ImmersionBar;
import com.luck.picture.lib.PictureSelector;
import com.luck.picture.lib.config.PictureConfig;
import com.luck.picture.lib.config.PictureMimeType;
import com.luck.picture.lib.entity.LocalMedia;
import com.makeramen.roundedimageview.RoundedImageView;
import com.qyhl.module_practice.R;
import com.qyhl.module_practice.R2;
import com.qyhl.webtv.basiclib.base.BaseActivity;
import com.qyhl.webtv.basiclib.base.BaseIViewPresenter;
import com.qyhl.webtv.basiclib.utils.StringUtils;
import com.qyhl.webtv.commonlib.common.CommonUtils;
import com.qyhl.webtv.commonlib.constant.ARouterPathConstant;
import com.qyhl.webtv.commonlib.constant.ServicePathConstant;
import com.qyhl.webtv.commonlib.entity.UpTokenBean;
import com.qyhl.webtv.commonlib.entity.act.UploadBean;
import com.qyhl.webtv.commonlib.entity.civilized.PracticeListBean;
import com.qyhl.webtv.commonlib.entity.civilized.PracticeSignBean;
import com.qyhl.webtv.commonlib.entity.civilized.PracticeSignOrgBean;
import com.qyhl.webtv.commonlib.entity.civilized.PracticeSignTagBean;
import com.qyhl.webtv.commonlib.service.ChannelConfigService;
import com.qyhl.webtv.commonlib.utils.action.ActionConstant;
import com.qyhl.webtv.commonlib.utils.action.ActionLogUtils;
import com.qyhl.webtv.commonlib.utils.eventbus.BusFactory;
import com.qyhl.webtv.commonlib.utils.eventbus.Event;
import com.qyhl.webtv.commonlib.utils.qiniu.QiniuUpload;
import com.qyhl.webtv.commonlib.utils.qiniu.UploadResultListener;
import com.qyhl.webtv.commonlib.utils.router.RouterManager;
import com.weavey.loading.lib.LoadingLayout;
import com.zhy.adapter.recyclerview.CommonAdapter;
import com.zhy.adapter.recyclerview.MultiItemTypeAdapter;
import com.zhy.adapter.recyclerview.base.ViewHolder;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;

import butterknife.BindView;
import butterknife.OnClick;

@Route(path = ARouterPathConstant.PRACTICE_VOLUNTEER_SIGN)
public class PracticeVolunteerSignActivity extends BaseActivity implements PracticeVolunteerSignContract.PracticeVolunteerSignView {
    @BindView(R2.id.title)
    TextView title;
    @BindView(R2.id.name)
    EditText name;
    @BindView(R2.id.sex)
    RadioGroup sex;
    @BindView(R2.id.team_rg)
    RadioGroup teamRg;
    @BindView(R2.id.phone)
    TextView phone;
    @BindView(R2.id.address)
    EditText address;
    @BindView(R2.id.political_spinner)
    Spinner politicalSpinner;
    @BindView(R2.id.table2)
    LinearLayout table2;
    @BindView(R2.id.recycle_view)
    RecyclerView recycleView;
    @BindView(R2.id.table3)
    CardView table3;
    @BindView(R2.id.load_mask)
    LoadingLayout loadMask;
    @BindView(R2.id.more)
    TextView more;
    @BindView(R2.id.table5)
    CardView table5;
    @BindView(R2.id.recycle_view2)
    RecyclerView recycleView2;
    @BindView(R2.id.load_mask2)
    LoadingLayout loadMask2;
    @BindView(R2.id.more2)
    TextView more2;
    @BindView(R2.id.head_icon)
    RoundedImageView headIcon;
    @BindView(R2.id.head_layout)
    RelativeLayout headLayout;
    @BindView(R2.id.workplace)
    EditText workPlace;
    @BindView(R2.id.team)
    TextView team;
    @BindView(R2.id.identity)
    EditText identity;
    @BindView(R2.id.identity_layout)
    LinearLayout identityLayout;
    @BindView(R2.id.address_layout)
    LinearLayout addressLayout;
    @BindView(R2.id.workplace_layout)
    LinearLayout workplaceLayout;

    @Autowired(name = ServicePathConstant.GET_CONFIG_INFO)
    ChannelConfigService channelConfigService;

    /**
     * 上传token
     */
    private UpTokenBean mUpToken;
    /**
     * 图片多选
     */
    public static final int CHOOSE_REQUEST = 200;

    public static final int RESULT_REQUEST = 202;


    /**
     * 图片数据
     */
    private List<LocalMedia> selectedList = new ArrayList<>();

    private PracticeVolunteerSignPresenter mPresenter;

    private String upLoadSex = "女";

    private String upLoadPoliticalStatus;

    private CommonAdapter commonAdapter;

    private CommonAdapter commonAdapter2;


    private List<PracticeSignTagBean> mDataList = new ArrayList<>();

    private List<PracticeSignTagBean> indexList = new ArrayList<>();

    private List<PracticeSignTagBean> mDataList2 = new ArrayList<>();

    private List<PracticeSignTagBean> indexList2 = new ArrayList<>();

    private List<PracticeSignOrgBean> orgBeanList = new ArrayList<>();

    private List<PracticeListBean> instList = new ArrayList<>();

    private List<PracticeSignOrgBean.PracticeSignOrgList> orgCheckedList = new ArrayList<>();

    private Status status = Status.COLLAPSED;

    private Status status2 = Status.COLLAPSED;

    private enum Status {
        EXPAND,
        COLLAPSED
    }

    private String upLoadAddress, upLoadName, upLoadPhone, upLoadTagIds, upLoadOrgIds, upLoadWorkPlace, upLoadIdentity;

    private CommonAdapter adapter;

    private int indexPosition = 0;


    @Override
    protected int getContentView() {
        return R.layout.practice_activity_volunteer_sign;
    }

    @Override
    protected void setImmersionBar(ImmersionBar mImmersionBar) {
        setDefaultImmerBar();
    }

    @Override
    protected BaseIViewPresenter initBaseIViewPresenter() {
        return null;
    }

    @Override
    protected void init() {
        String instId = getIntent().getStringExtra("instId");
        String titleName = getIntent().getStringExtra("title");
        mPresenter = new PracticeVolunteerSignPresenter(this);

        if (channelConfigService.getSiteId() == 175) {
            addressLayout.setVisibility(View.GONE);
            workplaceLayout.setVisibility(View.GONE);
            identityLayout.setVisibility(View.VISIBLE);
        } else {
            addressLayout.setVisibility(View.VISIBLE);
            workplaceLayout.setVisibility(View.VISIBLE);
            identityLayout.setVisibility(View.GONE);
        }

        upLoadPhone = CommonUtils.getInstance().getUserName();
        phone.setHint(upLoadPhone);

        loadMask.setStatus(LoadingLayout.Loading);
        table2.setVisibility(View.VISIBLE);
        table3.setVisibility(View.VISIBLE);
        headLayout.setVisibility(View.VISIBLE);

        if (StringUtils.isEmpty(titleName)) {
            title.setText("申请志愿者");
        } else {
            title.setText(titleName);
        }


        mPresenter.getTagList();
        mPresenter.getTeamTag();
        mPresenter.getInstList(instId);

        recycleView.setLayoutManager(new GridLayoutManager(this, 3));
        recycleView.setAdapter(commonAdapter = new CommonAdapter<PracticeSignTagBean>(this, R.layout.practice_item_sign_option, mDataList) {
            @Override
            protected void convert(ViewHolder holder, PracticeSignTagBean bean, final int position) {
                ToggleButton option = holder.getView(R.id.option);
                option.setTextOff(bean.getName());
                option.setTextOn(bean.getName());
                option.setChecked(bean.isChecked());

                option.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
                    @Override
                    public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
                        if (!buttonView.isPressed()) {
                            return;
                        }
                        mDataList.get(position).setChecked(isChecked);
                        indexList.get(position).setChecked(isChecked);
                    }
                });
            }
        });

        recycleView2.setLayoutManager(new GridLayoutManager(this, 3));
        recycleView2.setAdapter(commonAdapter2 = new CommonAdapter<PracticeSignTagBean>(this, R.layout.practice_item_sign_option, mDataList2) {
            @Override
            protected void convert(ViewHolder holder, PracticeSignTagBean bean, final int position) {
                ToggleButton option = holder.getView(R.id.option);
                option.setTextOff(bean.getName());
                option.setTextOn(bean.getName());
                option.setChecked(bean.isChecked());

                option.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
                    @Override
                    public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
                        if (!buttonView.isPressed()) {
                            return;
                        }
                        mDataList2.get(position).setChecked(isChecked);
                        indexList2.get(position).setChecked(isChecked);
                    }
                });
            }
        });

    }

    @Override
    protected void setListener() {
        sex.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() {
            @Override
            public void onCheckedChanged(RadioGroup group, int checkedId) {
                if (checkedId == R.id.sex_male) {
                    upLoadSex = "男";
                } else {
                    upLoadSex = "女";
                }
            }
        });

        teamRg.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() {
            @Override
            public void onCheckedChanged(RadioGroup group, int checkedId) {
                if (checkedId == R.id.team_join) {
                    team.setVisibility(View.VISIBLE);
                } else {
                    team.setVisibility(View.GONE);
                }
            }
        });


        politicalSpinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
            @Override
            public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
                switch (position) {
                    case 0:
                        upLoadPoliticalStatus = "群众";
                        break;
                    case 1:
                        upLoadPoliticalStatus = "党员";
                        break;
                    case 2:
                        upLoadPoliticalStatus = "团员";
                        break;
                    default:
                        upLoadPoliticalStatus = "群众";
                        break;
                }
            }

            @Override
            public void onNothingSelected(AdapterView<?> parent) {

            }
        });


        loadMask.setOnReloadListener(new LoadingLayout.OnReloadListener() {
            @Override
            public void onReload(View v) {
                loadMask.setReloadButtonText("加载中...");
                mPresenter.getTagList();

            }
        });

        loadMask2.setOnReloadListener(new LoadingLayout.OnReloadListener() {
            @Override
            public void onReload(View v) {
                loadMask.setReloadButtonText("加载中...");
                mPresenter.getTeamTag();

            }
        });
    }


    @OnClick({R2.id.back_btn, R2.id.more, R2.id.commit, R2.id.head_icon, R2.id.more2, R2.id.team})
    public void onViewClicked(View view) {
        int id = view.getId();
        if (id == R.id.back_btn) {
            finish();
        } else if (id == R.id.more) {
            if (status == Status.COLLAPSED) {
                status = Status.EXPAND;
                more.setText("收起更多选项");
                mDataList.clear();
                mDataList.addAll(indexList);
                commonAdapter.notifyDataSetChanged();
            } else {
                status = Status.COLLAPSED;
                more.setText("查看更多选项");
                if (indexList.size() > 6) {
                    mDataList.clear();
                    for (int i = 0; i < 6; i++) {
                        mDataList.add(indexList.get(i));
                    }
                    commonAdapter.notifyDataSetChanged();
                }
            }
        } else if (id == R.id.more2) {
            if (status2 == Status.COLLAPSED) {
                status2 = Status.EXPAND;
                more2.setText("收起更多选项");
                mDataList2.clear();
                mDataList2.addAll(indexList2);
                commonAdapter2.notifyDataSetChanged();
            } else {
                status2 = Status.COLLAPSED;
                more2.setText("查看更多选项");
                if (indexList2.size() > 6) {
                    mDataList2.clear();
                    for (int i = 0; i < 6; i++) {
                        mDataList2.add(indexList2.get(i));
                    }
                    commonAdapter2.notifyDataSetChanged();
                }
            }
        } else if (id == R.id.commit) {
            checkData();
        } else if (id == R.id.head_icon) {
            PictureSelector.create(PracticeVolunteerSignActivity.this)
                    //仅图片
                    .openGallery(PictureMimeType.ofImage())
                    //每行显示4张
                    .imageSpanCount(4)
                    .maxSelectNum(1)
                    .enableCrop(true)
                    .withAspectRatio(1, 1)
                    .selectionMode(PictureConfig.MULTIPLE)
                    //允许使用相机
                    .isCamera(true)
                    //允许预览图片
                    .previewImage(true)
                    .isZoomAnim(true)
                    .compress(true)
                    .selectionMedia(selectedList)
                    // 小于100kb的图片不压缩
                    .minimumCompressSize(100)
                    .forResult(CHOOSE_REQUEST);
        } else if (id == R.id.team) {
            if (orgBeanList != null && orgBeanList.size() > 0) {
                Bundle bundle = new Bundle();
                bundle.putSerializable("list", (Serializable) orgBeanList);

                RouterManager.router(this, ARouterPathConstant.PRACTICE_TAG_SEARCH, bundle, RESULT_REQUEST);
            } else {
                showToast("暂无任何队伍！", 4);
            }
        }
    }

    private void checkData() {
        showSimpleLoading();
        if (!CommonUtils.getInstance().getUserCheck().equals("1") && CommonUtils.getInstance().getSite() == 217 && CommonUtils.getInstance().getSite() == 217) {
            showToast("用户信息审核中，暂时无法使用该功能！", INFO);
            return;
        }

        upLoadName = name.getText().toString();
        if (StringUtils.isEmpty(upLoadName)) {
            showToast("请填写真实姓名！", 4);
            dismissLoading();
            return;
        }

        if (StringUtils.isEmpty(upLoadSex)) {
            showToast("请选择性别！", 4);
            dismissLoading();
            return;
        }


        if (StringUtils.isEmpty(phone.getText().toString())) {
            upLoadPhone = phone.getHint().toString();
        } else {
            upLoadPhone = phone.getText().toString();
            if (!StringUtils.isMobileNO(upLoadPhone)) {
                showToast("请填写正确的手机号！", 4);
                dismissLoading();
                return;
            }
        }


        if (teamRg.getCheckedRadioButtonId() == R.id.team_join) {
            StringBuilder orgIds = new StringBuilder();
            for (int i = 0; i < orgCheckedList.size(); i++) {
                orgIds.append(orgCheckedList.get(i).getId());
            }

            upLoadOrgIds = orgIds.toString();
            if (StringUtils.isEmpty(upLoadOrgIds)) {
                showToast("请选择队伍！", 4);
                dismissLoading();
                return;
            }
        } else {
            upLoadOrgIds = "";
        }

        if (channelConfigService.getSiteId() == 175) {
            upLoadIdentity = identity.getText().toString();
            if (!StringUtils.isIdentityNum(upLoadIdentity)) {
                showToast("请填写正确的身份证号码！", 4);
                dismissLoading();
                return;
            }

            upLoadWorkPlace = "";
            upLoadAddress = "";
        } else {
            upLoadIdentity = "";
            upLoadAddress = address.getText().toString();
            if (StringUtils.isEmpty(upLoadAddress)) {
                showToast("请填写户籍地！", 4);
                dismissLoading();
                return;
            }

            upLoadWorkPlace = workPlace.getText().toString();

        }


        if (StringUtils.isEmpty(upLoadPoliticalStatus)) {
            showToast("请选择政治面貌！", 4);
            dismissLoading();
            return;
        }

        StringBuilder tagIds = new StringBuilder();
        for (int i = 0; i < indexList.size(); i++) {
            if (indexList.get(i).isChecked()) {
                tagIds.append(indexList.get(i).getId()).append(",");
            }
        }

        upLoadTagIds = tagIds.toString();
        if (StringUtils.isEmpty(upLoadTagIds)) {
            showToast("至少选择一个服务类型！", 4);
            dismissLoading();
            return;
        }


        if (selectedList == null || selectedList.size() < 1) {
            showToast("请上传头像！", 4);
            dismissLoading();
//                mPresenter.doSignForVolunteer(upLoadSex, upLoadAddress, upLoadPoliticalStatus, upLoadName, upLoadPhone, "", upLoadTagIds, upLoadOrgIds, upOrgName, upOrgDesc, upOrgInstId, upOrgTagIds, upContract, upLoadWorkPlace);
        } else {
            if (mUpToken == null) {
                mPresenter.getToken(true);
                return;
            }
            List<UploadBean> uploadBeans = new ArrayList<UploadBean>();
            for (int i = 0; i < selectedList.size(); i++) {
                LocalMedia image = selectedList.get(i);
                UploadBean videoCoverBean = new UploadBean();
                videoCoverBean.setType(2);
                videoCoverBean.setPath(image.getCompressPath());
                videoCoverBean.setPostion(0);
                uploadBeans.add(videoCoverBean);
            }
            QiniuUpload.getQiniuUpload().UploadFiles(uploadBeans, mUpToken.getUptoken(), mUpToken.getPrefix(), new UploadResultListener() {
                @Override
                public void uplaodError() {
                    dismissLoading();
                    showToast("上传图片出错", INFO);
                }

                @Override
                public void uploadSuccess(List<UploadBean> files) {
                    Log.i("practice_act_apply", "uploadSuccess");
                    StringBuilder stringBuilder = new StringBuilder();
                    for (int i = 0; i < files.size(); i++) {
                        if (i == files.size() - 1) {
                            stringBuilder.append(files.get(i).getUrl());
                        } else {
                            stringBuilder.append(files.get(i).getUrl()).append(",");
                        }
                    }

                    mPresenter.doSignForVolunteer(upLoadSex, upLoadAddress, upLoadPoliticalStatus, upLoadName, upLoadPhone, stringBuilder.toString()
                            , upLoadTagIds, upLoadOrgIds, "", "", "", "", "", upLoadWorkPlace, upLoadIdentity);

                }

                @Override
                public void uploadPre(double percent) {

                }
            });
        }

    }

    @Override
    public void signSuccess(String msg) {
        dismissLoading();
        showToast(msg, 4);
        BusFactory.getBus().post(new Event.PracticeActRefresh(0));
        BusFactory.getBus().post(new Event.PracticeCenterRefresh(0));
        finish();
    }

    @Override
    public void signFailure(List<ContractBean> beanList, String msg) {
        dismissLoading();
        if (beanList == null || beanList.size() < 1) {
            showToast(msg, 4);
        } else {
            showToast(msg, 4);
        }

    }

    private void changeData(int position, boolean isRefresh) {
        for (int i = 0; i < instList.size(); i++) {
            if (i == position) {
                instList.get(i).setChecked(true);
            } else {
                instList.get(i).setChecked(false);
            }
        }
        if (isRefresh) {
            adapter.notifyDataSetChanged();
        }
    }

    @Override
    public void setList(List<PracticeListBean> beanList) {
        instList.clear();
        instList.addAll(beanList);
        int mPosition = 0;
        changeData(mPosition, false);

        adapter = new CommonAdapter<PracticeListBean>(PracticeVolunteerSignActivity.this, R.layout.practice_item_dialog_inst, instList) {
            @Override
            protected void convert(ViewHolder holder, PracticeListBean bean, int position) {
                holder.setText(R.id.name, bean.getName());
                if (bean.isChecked()) {
                    holder.setBackgroundRes(R.id.name, R.color.practice_dialog_inst_checked_bg);
                } else {
                    holder.setBackgroundRes(R.id.name, R.color.white);
                }
            }
        };

        adapter.setOnItemClickListener(new MultiItemTypeAdapter.OnItemClickListener() {
            @Override
            public void onItemClick(View view, RecyclerView.ViewHolder holder, int position) {
                indexPosition = position;
                changeData(indexPosition, true);
            }

            @Override
            public boolean onItemLongClick(View view, RecyclerView.ViewHolder holder, int position) {
                return false;
            }
        });
    }

    @Override
    public void setError(String msg) {
        showToast(msg, 4);
    }

    @Override
    public void getTeamTagSuccess(List<PracticeSignTagBean> beanList) {
        if (beanList != null && beanList.size() > 0) {
            loadMask2.setStatus(LoadingLayout.Success);
            more2.setVisibility(View.VISIBLE);
            indexList2.clear();
            mDataList2.clear();
            indexList2.addAll(beanList);
            if (beanList.size() > 6) {
                for (int i = 0; i < 6; i++) {
                    mDataList2.add(beanList.get(i));
                }
                more2.setVisibility(View.VISIBLE);
            } else {
                more2.setVisibility(View.GONE);
                mDataList2.addAll(beanList);
            }
            commonAdapter2.notifyDataSetChanged();
        } else {
            more2.setVisibility(View.GONE);
            loadMask2.setStatus(LoadingLayout.Error);
            loadMask2.setReloadButtonText("点击重试~");
            loadMask2.setErrorText("暂无任何类型！");
        }
    }

    @Override
    public void getTeamTagError(String msg) {
        loadMask2.setStatus(LoadingLayout.Error);
        loadMask2.setReloadButtonText("点击重试~");
        loadMask2.setErrorText(msg);
    }

    @Override
    public void getTagSuccess(PracticeSignBean bean) {
        orgBeanList = bean.getOrgList();
        if (bean.getTagList() != null && bean.getTagList().size() > 0) {
            loadMask.setStatus(LoadingLayout.Success);
            more.setVisibility(View.VISIBLE);
            indexList.clear();
            mDataList.clear();
            indexList.addAll(bean.getTagList());
            if (bean.getTagList().size() > 6) {
                for (int i = 0; i < 6; i++) {
                    mDataList.add(bean.getTagList().get(i));
                }
                more.setVisibility(View.VISIBLE);
            } else {
                more.setVisibility(View.GONE);
                mDataList.addAll(bean.getTagList());
            }
            commonAdapter.notifyDataSetChanged();
        } else {
            more.setVisibility(View.GONE);
            loadMask.setStatus(LoadingLayout.Error);
            loadMask.setReloadButtonText("点击重试~");
            loadMask.setErrorText("暂无任何类型！");
        }
    }

    @Override
    public void getTagFailure(String msg) {
        loadMask.setStatus(LoadingLayout.Error);
        loadMask.setReloadButtonText("点击重试~");
        loadMask.setErrorText(msg);
    }

    @Override
    public void getTokenSuccess(UpTokenBean data, boolean isUpload) {
        mUpToken = data;
        if (isUpload) {
            checkData();
        }
    }

    @Override
    public void getTokenError(boolean isUpload) {
        if (isUpload) {
            dismissLoading();
            showToast("上传失败！", 4);
        }
    }

    @SuppressLint("SetTextI18n")
    @Override
    protected void onActivityResult(int requestCode, int resultCode, Intent data) {
        super.onActivityResult(requestCode, resultCode, data);
        switch (requestCode) {
            case RESULT_REQUEST:
                if (data != null && data.getExtras() != null) {
                    List<PracticeSignOrgBean> beanList = (List<PracticeSignOrgBean>) data.getExtras().getSerializable("list");
                    if (beanList != null && beanList.size() > 0) {
                        orgBeanList.clear();
                        orgCheckedList.clear();
                        orgBeanList.addAll(beanList);

                        for (int i = 0; i < beanList.size(); i++) {
                            List<PracticeSignOrgBean.PracticeSignOrgList> list
                                    = beanList.get(i).getOrgList();
                            for (int j = 0; j < list.size(); j++) {
                                if (list.get(j).isChecked()) {
                                    orgCheckedList.add(list.get(j));
                                }
                            }
                        }

                        if (orgCheckedList.size() > 0) {
                            if (orgCheckedList.size() == 1) {
                                team.setText(orgCheckedList.get(0).getName() + " >");
                            } else {
                                team.setText(orgCheckedList.get(0).getName() + "等 >");
                            }
                        } else {
                            team.setText("");
                        }

                    }
                }
                break;
            case CHOOSE_REQUEST:
                List<LocalMedia> resultList = PictureSelector.obtainMultipleResult(data);
                if (resultList != null && resultList.size() > 0) {
                    selectedList.clear();
                    selectedList.addAll(resultList);

                    Glide.with(this)
                            .load(selectedList.get(0).getCompressPath())
                            .apply(new RequestOptions().placeholder(R.drawable.comment_head_default).placeholder(R.drawable.comment_head_default))
                            .into(headIcon);
                }
                break;
        }
    }

    public class ContractBean implements Serializable {
        private String name;
        private String phone;

        ContractBean(String name, String phone) {
            this.name = name;
            this.phone = phone;
        }

        public String getName() {
            return name;
        }

        public void setName(String name) {
            this.name = name;
        }

        public String getPhone() {
            return phone;
        }

        public void setPhone(String phone) {
            this.phone = phone;
        }
    }


    @Override
    protected void onResume() {
        super.onResume();
        ActionLogUtils.getInstance().onResume(this, ActionConstant.PRACTICE_VOL_SIGN);
    }

    @Override
    protected void onPause() {
        super.onPause();
        ActionLogUtils.getInstance().onPause(this, ActionConstant.PRACTICE_VOL_SIGN);
    }

}
